package com.leetcode.August;

/**
 * @Description: 53. 最大子数组和
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-19 21:03
 */
public class LC53最大子数组和 {
    public int maxSubArray(int[] nums) {
        if (nums == null || nums.length==0)return 0;
        int max = nums[0];
        int current=nums[0];
        for (int i = 1; i < nums.length; i++) {
            current=Math.max(current+nums[i],nums[i]);
            max=Math.max(max,current );
        }
        return max;
    }
}
